<template>
    <div class="addressList">
        <div class="content">
            <nut-address-list
                :data="addressList"
                swipe-edition
                :show-bottom-button="false"
                @edit-icon="editClick"
                @click-item="clickItem"
                @swipe-del="delClickSwipe"
                :data-options="dataOptions"
            >
            </nut-address-list>
        </div>
        <div class="address-confirm">
            <div class="address-confirm-content">
                <nut-button type="info" shape="square" class="confirm-opera">确认</nut-button>
            </div>
        </div>
    </div>
  </template>
  
  <script>
  import { reactive, toRefs,isReactive } from 'vue';
  import './index.scss';
  import { Edit, Checklist } from '@nutui/icons-vue-taro';
  import Taro from '@tarojs/taro'
  import currency from 'currency.js'
import { stat } from 'fs';
  export default {
    name: 'Index',
    components: {
        Edit,Checklist
    },
    setup(){
      const state = reactive({
        addressList: [
            {
            testid:3,
            testaddressName:'姓名',
            phone:'123****4567',
            defaultAddress:false,
            fullAddress:'北京市通州区测试测试测试测试测试测试测试测试测试'
            },
            {
            testid:4,
            testaddressName:'姓名',
            phone:'123****4567',
            defaultAddress:true,
            fullAddress:'北京市通州区测试测试测试测试测试测试测试测试测试'
            },
        ]
      });
      const dataOptions = reactive({
        id: 'testid',
        addressDetail:'testaddressDetail',
        addressName:'testaddressName'
        });
      const clickItem = ()=>{
        console.log('Click To Address');
      }
      const editClick = ()=>{
        console.log('Click To Edit');
      }
      const delClickSwipe = () => {
        console.log('Click On DelClickSwipe');
      };
      const addAddress = ()=>{
        console.log('Click To Add');
      }
      const SelectTarAddress = (tar,tarIdx) => {
        state.addressList.forEach((i,idx) => {
            i.checkFlag = idx == tarIdx ? !i.checkFlag : false;
        });
      }
      const GoEditAddress = () => {
        console.log(1)
        Taro.navigateTo({
            url: `/pages/address-edit/index`
        })
      }
  
      return {
        dataOptions,
        SelectTarAddress,
        GoEditAddress,
        clickItem,
        editClick,
        delClickSwipe,
        addAddress,
        ...toRefs(state),
      }
    }
  }
  </script>
  
  